OPC Studio User's Guide and Reference
OPC Data Client REALbasic (Xojo) Examples
Examples > Examples in the Product and on the Web > OPC Data Client COM Examples > OPC Data Client REALbasic (Xojo) Examples
In This Topic

Note: We do not regularly update these examples with new versions. You may have to modify the code to use newer versions.

The REALbasic (Xojo) examples were originally created in REAL Studio 2010r5, and converted to REAL Studio 2011r1.1, and later versions. We also tested with Xojo 2019r3.1 and Xojo 2020r1.2.

Xojo Development Specifics

It appears to be impossible to enumerate COM collections using any built-in construct, or accessing the GetEnumerator method in Xojo. With most collections, you can, however, obtain the Count property of the collection, and then access the individual elements using the Item property, which is "indexed" by an integer, from 0 to Count - 1.

Some collections in OPC Data Client are, however, keyed collections, where the key is not an integer (or it might be an integer but it does not represent a sequential index into the collection). There is no direct way to enumerate elements of such keyed collections in Xojo.

To enumerate such collections, we recommend following workaround: Create an instance of ElasticVector Collection object, and call its AddRange Method, passing it the keyed collection you want to enumerate. This will effectively convert the key collection to an elastic vector, and you can then use the Item Property of the elastic vector (indexed by an integer) to access all elements of the original collection in a sequence.

With Multiple-operation Methods, it is highly recommended that you use the methods that accept and return lists (as opposed to arrays). Significant memory leaks have been observed when arrays from OPC Data Client are returned to Xojo.
In tight loops involving operations on COM components (in single-threaded apartments, which appears to be the default), your code should pump Windows messages, e.g. by calling App.DoEvents periodically.
See Also

Fundamentals

Knowledge Base

Examples - Client OPC Data Access

Concepts